<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>剪贴板</title>
</head>

<body>
	<div>
		<input type="text" id="txt" value="AABBCCDD"/>
		<input id="cpbtn" name="cpbtn" type="button" value="复制" onclick="copy('txt');"/>
	</div>
<script>
function copy(id) {
	var inElement = document.getElementById(id);
	if (inElement.createTextRange) {//IE
		var range = inElement.createTextRange();
		if (range && BodyLoaded==1){
			range.execCommand('Copy');
		}
	} else {//!IE
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) {
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(inElement.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		var el = document.getElementById(flashcopier);
		el.style.width="400px";
		el.style.height="350px";
		el.style.backgroundColor="lightblue";
		el.innerHTML = divinfo;
	}
}
</script>
</body>
</html>
